package activity.video.utils;

import android.util.Log;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;

import bean.VideoInfo;

/**
 * 按时间
 * Created by lt on 2018\3\2 0002.
 */

public class TimeComparator implements Comparator<VideoInfo> {
    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    @Override
    public int compare(VideoInfo o1, VideoInfo o2) {
        try {
            long date1=sdf.parse(o1.getStart_time()).getTime();
            long date2=sdf.parse(o2.getStart_time()).getTime();
            Log.i("tedu","--o1--:"+o1.getTime()+"----"+o1.getFilename());
            if(date1>date2){
                return -1;
            }else if (date1==date2) {
                return 0;
            }else {
                return 1;
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 1;
    }
}
